package com.ruoyi.sys.vehile.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sys.vehile.domain.TbMonthCardList;
import com.ruoyi.sys.vehile.service.ITbMonthCardListService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 月卡列Controller
 *
 * @author ruoyi
 * @date 2022-05-24
 */
@RestController
@RequestMapping("/system/list")
public class TbMonthCardListController extends BaseController
{
    @Autowired
    private ITbMonthCardListService tbMonthCardListService;

    /**
     * 查询月卡列列表
     */
    @PreAuthorize("@ss.hasPermi('system:list:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbMonthCardList tbMonthCardList)
    {
        startPage();
        List<TbMonthCardList> list = tbMonthCardListService.selectTbMonthCardListList(tbMonthCardList);
        return getDataTable(list);
    }

    /**
     * 导出月卡列列表
     */
    @PreAuthorize("@ss.hasPermi('system:list:export')")
    @Log(title = "月卡列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbMonthCardList tbMonthCardList)
    {
        List<TbMonthCardList> list = tbMonthCardListService.selectTbMonthCardListList(tbMonthCardList);
        ExcelUtil<TbMonthCardList> util = new ExcelUtil<TbMonthCardList>(TbMonthCardList.class);
        util.exportExcel(response, list, "月卡列数据");
    }

    /**
     * 获取月卡列详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:list:query')")
    @GetMapping(value = "/{mcId}")
    public AjaxResult getInfo(@PathVariable("mcId") Long mcId)
    {
        return AjaxResult.success(tbMonthCardListService.selectTbMonthCardListByMcId(mcId));
    }

    /**
     * 新增月卡列
     */
    @PreAuthorize("@ss.hasPermi('system:list:add')")
    @Log(title = "月卡列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbMonthCardList tbMonthCardList)
    {
        return toAjax(tbMonthCardListService.insertTbMonthCardList(tbMonthCardList));
    }

    /**
     * 修改月卡列
     */
    @PreAuthorize("@ss.hasPermi('system:list:edit')")
    @Log(title = "月卡列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbMonthCardList tbMonthCardList)
    {
        return toAjax(tbMonthCardListService.updateTbMonthCardList(tbMonthCardList));
    }

    /**
     * 删除月卡列
     */
    @PreAuthorize("@ss.hasPermi('system:list:remove')")
    @Log(title = "月卡列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mcIds}")
    public AjaxResult remove(@PathVariable Long[] mcIds)
    {
        return toAjax(tbMonthCardListService.deleteTbMonthCardListByMcIds(mcIds));
    }
}
